import {  View } from "react-native"
import { GridOne, ObserverText } from "../../components"
import { postRecommend } from "../../services"
import {  memo, useEffect, useState } from "react"
import { dpw12, dpw16 } from "../../constants"

const Recommend = ({navigation, typeId}: any) => {
    const [data, setData] = useState([])
    
    // 获取列表数据
    useEffect(() => {
       postRecommend({ Type: typeId})
            .then((res: any) => {
                if (Array.isArray(res?.Data)) {
                    setData(res.Data)
                } else {
                    throw new Error("");
                }
            }).catch(() => { })
    }, [typeId]);
    
    return (
        <View>
            <ObserverText style={{ marginBottom: dpw12, marginHorizontal: dpw16 }} tKey="recommended" type="model-title" />
            <GridOne list={data as any[]} typeId={1} navigation={navigation} />
        </View>
    )
}

export default memo(Recommend)